<?php /*a:2:{s:59:"E:\wamp64\www\tp5\miqicms\app\admin\view\doc_con\index.html";i:1667544371;s:57:"E:\wamp64\www\tp5\miqicms\app\admin\view\public\base.html";i:1667268361;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 <title>title2233</title>
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1:8000/static/admin/static/css/style.css" />
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1:8000/static/admin/layui/css/layui.css" />
</head>
    <style type="text/css">
      .layui-laypage li {float:left !important;}
    </style>
<script>
  var Oper = {
    submit_yes : true,
    layui : false,
    layer : false,
    jq : false,
    form : false,
    element : false,
    table : false,
    key : 'id',
    //一些按钮的事件绑定
    config : {
      //开关
      'switch' : 'switch(status)',
      //添加
      'add' : {
        'element' : '#btn-add',
        'name' : '添加',
        'width' : '600px',
        'height' : '460px',
        'method' : 'add',
      },
      //编辑
      'edit' : {
        'element' : 'tbody#userList tr td #edit',
        'width' : '600px',
        'height' : '520px',
      },
    //编辑
    // 'edit' : {
    //     'element' : '.plugin_edit',
    //     'width' : '600px',
    //     'height' : '520px',
    // },
      //删除
      'delete' : {
        'element' : 'tbody#userList tr td #delete',
        'all' : '#btn-alldel',
        'method' : 'delete',
      },
    },
    set : function(layui, name, module, key) {
      var self = this;
      self.layui = layui;
      self.layer = layui.layer;
      self.jq = layui.jquery;
      self.form = layui.form;
      self.element = layui.element;
      self.table = layui.table;
      self.name = name;
      self.module = module;
      self.checked = [];
      self.key = key;
    }

    //列表页
    ,initList : function(layui, name, module, key) {
      var self = this;
      self.set(layui, name, module, key);

      self.jq(function() {
        self.switch();
        self.add();
        self.edit();
        self.delete();
        self.checkall();
      });
    }

    //更新页 暂未实现
    ,initUpdate : function(layui, name, form_id, update_url, list_url, editor, tag) {
      var self = this;
      self.set(layui, name, false, false);
      self.jq(function() {
        self.tag(tag);
        self.editor(editor);
        self.submit(form_id, update_url, list_url, editor);
      });
    }

    ,remove : function(a, v) {
      for (var i = 0; i < a.length; i++) {
        if (a[i] == v) a.splice(i, 1);
      }
      return -1;
    }

    ,msg : function(msg, option, func) {
      if (!option) {
        option = {
          time:1800
        };
      }
      if (func == 'reload') {
        func = function() {
          location.reload();
        }
      } else {
        func = false;
      }
      this.layer.msg(msg, option, func);
    }

    ,switch : function() {
      var self = this;
      self.form.on(self.config.switch, function(data) {
        var url = self.jq(this).attr('data-uri');
        var val = '';
        if (data.elem.checked == true) {
          val = 1;
        } else {
          val = 0;
        }

        self.jq.post(url + "&val=" + val, data.field, function(res) {
          if (res.status ==  1) {
            self.msg('更新成功');
          } else {
            self.msg('更新失败');
          }
        });
      });
    }

    // //初始化标签
    ,tag : function(tag) {
      //自动获取标签
      if (!tag) {
        return;
      }
      var self = this;
      self.jq(tag).on('click', function() {
        var title = self.jq.trim(self.jq('#J_title').val());
        if(title == ''){
          layer.msg('请先填写标题',{time:1800});
          return false;
        }
        self.jq.getJSON('', {title:title}, function(result){
          if(result.status == 1){
            self.jq('#tpt_input').val(result.data);
          }else{
            self.layer.msg('获取失败',{time:1800});
          }
        });
      });
    }

    // //初始化编辑器
    ,editor : function(editor)
    {
      if (!editor) {
        return;
      }
      var self = this;
      self.editors = {};
      for (var i in editor) {
        //编辑器图片上传
        self.layui.layedit.set({
          uploadImage: {
            url: '<?php echo url("attachment/editer_upload"); ?>',
            type: 'post'
          }
        });
        //构建一个默认的编辑器
        self.editors[editor[i]] = self.layui.layedit.build(editor[i]);
      }
    }

    // //提交按钮
    ,submit : function(form_id, update_url, list_url, editor) {
      var self = this;
      var loading = false;

      self.layui.form.on('submit('+form_id+')', function(data){
        if (self.submit_yes == false) {
          return false;
        }
        self.submit_yes = false;
        if (list_url) {
          loading = self.layer.load(2, {shade: [0.2,'#000']});
        }
        if (editor) {
          for (var i in editor) {
            data.field[editor[i]] = self.layui.layedit.getContent(self.editors[editor[i]]);
          }
        }
        var url = "";
        var temp = update_url.split('/');
        var post_url = url.replace('module', temp[0]);
        post_url = post_url.replace('method', temp[1]);
        self.jq.post(post_url,data.field,function(data){
          if(data.status ==  1){
            if (list_url) {
              if (loading) {
                self.layer.close(loading);
              }
              self.layer.msg(data.msg,{time:1800},function(){
                var temp = list_url.split('/');
                list_url = url.replace('module', temp[0]);
                list_url = list_url.replace('method', temp[1]);
                self.submit_yes = true;
                location.href = list_url;
              });
            } else {
              self.layer.msg(data.msg,{time:1800},function(){
                self.submit_yes = true;
                //关闭弹层后刷新父页面
                window.parent.location.reload();
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
              });
            }
          }else{
            self.submit_yes = true;
            if (list_url) {
              self.layer.msg(data.msg,{time:1800});
              if (loading) {
                self.layer.close(loading);
              }
              return false;
            } else {
              self.layer.msg(data.msg,{time:1800});
              return false;
            }
          }
        });
        return false;
      });
    }

    //添加
    ,add : function() {
      var self = this;
      this.jq(self.config.add.element).click(function() {
        var url = "<?php echo url('module/method'); ?>";
        url = url.replace('module', self.module);
        url = url.replace('method', self.config.add.method);
        self.layer.open({
          type: 2,
          title: self.config.add.name + self.name,
          area: [self.config.add.width, self.config.add.height],
          fixed: true,
          maxmin: true,
          content: url
        });
      });
    }

    //编辑
    ,edit : function() {
      var self = this;
      self.jq(self.config.edit.element).click(function() {
        var title   = self.jq(this).attr('data-title');
        var url   = self.jq(this).attr('data-uri');
        self.layer.open({
          type: 2,
          title: title,
          area: [self.config.edit.width, self.config.edit.height],
          fixed: true,
          maxmin: true,
          content: url
        });
      });
    }


    //全选
    ,checkall : function() {
      var self = this;
      self.form.on('checkbox(allChoose)', function(data) {
        var child = self.jq(data.elem).parents('table').find('.doc_checkbox');

        child.each(function(index, item) {
          item.checked = data.elem.checked;
          if (item.checked) {
            self.checked.push(self.jq(this).val());
          } else {
            self.remove(self.checked, self.jq(this).val());
          }
        });
        self.form.render('checkbox');
      });
      self.form.on('checkbox(itemChoose)',function(data) {
        if (data.elem.checked) {
          self.checked.push(self.jq(this).val());
        } else {
          self.remove(self.checked, self.jq(this).val());
        }
      });
    }

    //删除
    ,delete : function() {
      var self = this;
      self.jq(self.config.delete.element).click(function(data) {
        var id  = self.jq(this).attr('data-id');
        var url = self.jq(this).attr('data-uri');
        self.deleteAction(url);
      });

      self.deleteAll();
    }

    //批量删除
    ,deleteAll : function() {
      var self = this;
      if (this.jq(self.config.delete.all).length) {
        this.jq(self.config.delete.all).click(function(data) {
          if (!self.checked || self.checked.length <= 0) {
            self.msg('请选择需要删除的数据');
          } else {
            var url = "<?php echo url('module/method', array('me' => 1)); ?>";
            url = url.replace('module', self.module);
            url = url.replace('method', self.config.delete.method);
            var url = url + "&"+self.key+"=" + self.checked.join(',');
            self.deleteAction(url);
          }
        });
      }
    }

    //确认删除
    ,deleteAction : function(url, param) {
      if (!param) {
        param = {};
      }
      var self = this;
      self.layer.confirm('删除'+self.name+'将不能恢复，确认删除吗？'
              , {btn: ['确认','取消']}
              , function() {
                self.jq.post(url, param, function(res) {
                  if(res.status ==  1) {
                    self.msg(res.msg, false, 'reload');
                  } else {
                    self.msg(res.msg);
                    return false;
                  }
                });
              }
              , function() {
                self.msg('取消删除');
                return false;
              }
      );
      return false;
    }
  };
</script>
<script type="text/javascript" src="http://127.0.0.1:8000/static/admin/layui/layui.js"></script>
<body class="body">

<style type="text/css">
    .red {color: #FF5722!important;}
    .green {color: #5FB878!important;}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top:0px;">
    <legend><?php echo htmlentities(getmenuname($menuid)); ?></legend>
</fieldset>
<form class="layui-form layui-form-pane" action="">
    <input type="hidden" name="menuid" value="67" />
    <div class="my-btn-box"> <span class="fl">
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">所属栏目</label>
        <div class="layui-input-inline">
          <select name="cid">
            <option value=""></option>
                <?php if(is_array($catelist) || $catelist instanceof \think\Collection || $catelist instanceof \think\Paginator): $i = 0; $__LIST__ = $catelist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?>
                       <option value="<?php echo htmlentities($val['id']); ?>" <?php if((isset($searchArr['cid']) && ($searchArr['cid'] !== '')?$searchArr['cid']:'') == $val['id']): ?>selected="selected"<?php endif; ?>><?php echo htmlentities($val['name']); ?></option>
                        <?php if(is_array($val['erji']) || $val['erji'] instanceof \think\Collection || $val['erji'] instanceof \think\Paginator): $i = 0; $__LIST__ = $val['erji'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                           <option value="<?php echo htmlentities($vo['id']); ?>" <?php if((isset($searchArr['cid']) && ($searchArr['cid'] !== '')?$searchArr['cid']:'') == $vo['id']): ?>selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;├─ <?php echo htmlentities($vo['name']); ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
          </select>
        </div>
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline" style="width:100px">
          <select name="status" lay-filter="status" >
              <option value="" selected="selected">所有</option>
              <option value="1" <?php if((isset($searchArr['status']) && ($searchArr['status'] !== '')?$searchArr['status']:'') == '1'): ?>selected="selected"<?php endif; ?>>已审核</option>
              <option value="0" <?php if((isset($searchArr['status']) && ($searchArr['status'] !== '')?$searchArr['status']:'0') == '0'): ?>selected="selected"<?php endif; ?>>未审核</option>
          </select>
        </div>
        <label class="layui-form-label">关键词</label>
        <div class="layui-input-inline">
          <input type="tel" name="title" placeholder="文档关键词" lay-verify="required|phone" value="<?php echo htmlentities((isset($searchArr['title']) && ($searchArr['title'] !== '')?$searchArr['title']:'')); ?>" class="layui-input">
        </div>
        <div class="layui-input-inline">
          <button class="layui-btn mgl-20">搜索</button>
        </div>
      </div>
    </div>
    </span>
        <span class="fr">
        <a href="<?php echo url('doc_con/index', array('menuid'=>1)); ?>" class="layui-btn mgl-20">显示全部</a>
        <a class="layui-btn layui-btn-danger" id="btn-alldel">批量删除</a>
            <a class="layui-btn layui-btn-normal" id="btn-add">添加文档</a>
        </span> </div>
</form>
<form class="layui-form layui-form-pane" action="">
    <table class="layui-table">
        <colgroup>
            <col width="60">
            <col width="50">
            <col width="">
            <col width="120">
            <col width="120">
            <col width="120">
            <col width="80">
            <col width="150">
            <col width="100">
            <col width="80">
            <col width="100">
        </colgroup>
        <thead>
        <tr>
            <th><input type="checkbox" id="checkall_t" lay-skin="primary" lay-filter="allChoose" ></th>
            <th>ID</th>
            <th>文档标题</th>
            <th>所属专辑</th>
            <th>所属栏目</th>
            <th>作者</th>
            <th>所需积分</th>
            <th>上传时间</th>
            <th>状态</th>
            <th>是否转换</th>
            <th>管理操作</th>
        </tr>
        </thead>
        <tbody id="userList">
        <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?>
            <tr>
                <td><input class="doc_checkbox" type="checkbox" value="<?php echo htmlentities($val['id']); ?>" lay-skin="primary" lay-filter="itemChoose"></td>
                <td><?php echo htmlentities($val['id']); ?></td>
                <td><a href="<?php echo url('home/doc/doccon',array('id'=>$val['id'])); ?>" target="_blank"><?php echo htmlentities($val['title']); ?></a></td>
                <td><?php echo htmlentities((isset($zjlist[$val['zjid']]) && ($zjlist[$val['zjid']] !== '')?$zjlist[$val['zjid']]:'无')); ?></td>
                <td><?php echo htmlentities($cate_list[$val['cid']]); ?></td>
                <td><?php echo htmlentities(getusername($val['uid'])); ?></td>
                <td><?php echo htmlentities($val['score']); ?></td>
                <td><?php echo htmlentities(date('Y-m-d H:i',!is_numeric($val['create_time'])? strtotime($val['create_time']) : $val['create_time'])); ?></td>
                <td>
                    <input type="checkbox" name="status" value="<?php echo htmlentities($val['status']); ?>" data-uri="<?php echo url('doc_con/ajax_edit',['id'=>$val['id'],'field'=>'status']); ?>" lay-skin="switch" lay-filter="status" lay-text="审核|未审"   <?php if(($val['status'] == 1)): ?>checked<?php endif; ?>>
                </td>
                <td>
                    <?php echo htmlentities($val['convert_status_text']); ?>
                </td>

                <td>
                    <a href="javascript:;" class="J_showdialog" data-uri="<?php echo url('doc_con/edit', array('id'=>$val['id'])); ?>" data-title="编辑 - <?php echo htmlentities($val['title']); ?>"  data-id="edit" data-acttype="ajax" id="edit">编辑</a> |
                    <a href="javascript:void(0);" class="J_confirmurl" data-acttype="ajax" data-uri="<?php echo url('doc_con/delete', array('id'=>$val['id'])); ?>" id="delete" data-msg="<?php echo sprintf('确认要删除',$val['title']); ?>">删除</a>
                </td>
            </tr>
        <?php endforeach; endif; else: echo "" ;endif; ?>

        </tbody>
    </table>
</form>
<div id="test-laypage-demo0">
    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-29">
        <?php echo $list; ?>
    </div>
</div>

<script>
    layui.use(['layer','jquery','form','element','table'], function () {

        //编辑弹窗
        Oper.config.edit.height = '300px';
        Oper.config.edit.height = '520px';

        //参数：layui、名称、模块名、主键（删除用）
        Oper.initList(layui, '文档', 'doc_con', 'id');

    });
</script>


</body>
</html>